package org.example.first_demo.controler;

import org.example.first_demo.Service.CacheService;
import org.example.first_demo.Service.KafkaProducerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")

public class TestController_kafka_redis {

    @Autowired
    private CacheService cacheService;

    @Autowired
    private KafkaProducerService kafkaProducer;

    // Redis 测试接口
    @GetMapping("/redis/{key}")
    public String testRedis(@PathVariable String key) {
        return cacheService.getData(key);
    }

    // Kafka 测试接口
    @PostMapping("/kafka")
    public String testKafka(@RequestParam String message) {
        kafkaProducer.sendMessage(message);
        return "已发送: " + message;
    }
}
